import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';

// import { Device } from "@ionic-native/device";
// import { TabsPage } from './modules/main/pages/tabs/tabs.page';
// import {ResponseDistricts} from "./shared/models/response/response-districts";
// import {Observable} from "rxjs/Observable";
// import { HttpService } from "http-service";
// import { API } from "./shared/models/api-path-extension";
// import { SecureStorageService } from './shared/services/secure-storage.services';
// import {Network} from "@ionic-native/network";
// import {SyncPushService, NetStatus} from "./shared/services/offline/sync-push.service";
// import {SyncUtilService} from "./shared/services/offline/sync.util.service";
// import { LogonService } from "./shared/services/logon.services";
// import {RefreshTokenService} from "./shared/services/refresh-token.service";


@Component({
  templateUrl: 'app.page.html'
})
export class AppPage {
  rootPage: any = "HomePage";

  constructor(
    platform: Platform,
    statusBar: StatusBar,
    // network: Network,
    // syncPushService: SyncPushService,
    splashScreen: SplashScreen,
    // syncUtilService: SyncUtilService,
    // storage: SecureStorageService,
    // refreshToken: RefreshTokenService,
    // secureStorageService: SecureStorageService,
    // logonService: LogonService,
    // httpServie: HttpService
    ) {
    platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      statusBar.styleDefault();
      splashScreen.hide();
      // use our own secure storage service.
      // httpServie.tokenService = secureStorageService;
      // secureStorageService.ready().subscribe((ready: boolean) => {
      //   if (!ready) {
      //     alert("请设置锁屏密码后重新打开应用");
      //   }

      //   network.onchange()
      //     .subscribe(() => {
      //       console.log("network charged");
      //       syncUtilService.getApiLastFetchingDate(LastFetchingDate.pushTime)
      //         .subscribe((lastFetchingDate: any) => {
      //           // if (!lastFetchingDate) {
      //           //   return ;
      //           // }
      //           // if (+new Date() - lastFetchingDate > 60 * 1000) {
      //           if (new RegExp(network.type).test(NetStatus.work)) {
      //             logonService.loginVPN()
      //               .subscribe(() => {
      //                   syncPushService.startPush()
      //                     .subscribe(() => {
      //                       // TODO
      //                     });
      //               });
      //           }
      //           // }
      //       });
      //   });


      // }, (error: any) => {
      //   alert("请设置锁屏密码后重新打开应用");
      // });

    });


  }

  goPage(page) {
    this.rootPage = page;
  }


}
